package com.yxjx.duoxue.datamodel.school;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

import com.yxjx.duoxue.datamodel.DMObject;
import com.yxjx.duoxue.utils.UIHelper;

/**
 * 服务
 *
 * @author zhangxs
 * @date 2015年2月6日
 *
 */
public class SchoolDetailServiceDTS extends DMObject implements Serializable {

    /**
	 * 
	 */
	private static final long serialVersionUID = -9008035120210264926L;
	private String serviceDetailId = "";
    private String serviceDetail = "";

    public String getServiceDetailId() {
        return serviceDetailId;
    }

    public void setServiceDetailId(String serviceDetailId) {
        this.serviceDetailId = serviceDetailId;
    }

    public String getServiceDetail() {
        return serviceDetail;
    }

    public void setServiceDetail(String serviceDetail) {
        this.serviceDetail = serviceDetail;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((serviceDetail == null) ? 0 : serviceDetail.hashCode());
        result = prime * result + ((serviceDetailId == null) ? 0 : serviceDetailId.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        SchoolDetailServiceDTS other = (SchoolDetailServiceDTS) obj;
        if (serviceDetail == null) {
            if (other.serviceDetail != null)
                return false;
        } else if (!serviceDetail.equals(other.serviceDetail))
            return false;
        if (serviceDetailId == null) {
            if (other.serviceDetailId != null)
                return false;
        } else if (!serviceDetailId.equals(other.serviceDetailId))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "{\"serviceDetailId\":\"" + serviceDetailId + "\", \"serviceDetail\":\"" + serviceDetail + "\"}";
    }
    
    public static SchoolDetailServiceDTS from(String str) {
    	if (UIHelper.isEmpty(str)) {
    		return null;
    	}
    	
    	try {
			JSONObject jo = new JSONObject(str);
			SchoolDetailServiceDTS item = new SchoolDetailServiceDTS();
			item.setServiceDetail(castString(jo,"serviceDetail"));
			item.setServiceDetailId(castString(jo,"serviceDetailId"));
			return item;
		} catch (JSONException e) {
			e.printStackTrace();
			return null;
		}
    }

}